//
//  SingleListNetWork.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/8/16.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "SingleListNetWork.h"
#import "GFXNetworkHandle.h"

NSString * const OrderList = @"auth/order/buy/list";//订单列表
NSString * const FeeWineList = @"auth/my/free";//免费喝红酒订单列表
NSString * const SingleGotoPay = @"auth/buy/order/not/pay/go/to/pay";//去付款
NSString * const SingleDetail = @"auth/order/buy/detail";//订单详情
NSString * const SingleComment = @"auth/comment/buy/order";//评价商品

NSString * const ShopOrderList = @"auth/order/buy/shop/list";//商家待发货 已发货 退货

@implementation SingleListNetWork

+ (void)getSingleListWithParame:(NSDictionary *)parames type:(SingleType)type response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:OrderList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                SingleListModel *model = [SingleListModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)singleGotoPayWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,SingleCreateModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:SingleGotoPay params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            SingleCreateModel *model = [SingleCreateModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)singleDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,SingleListModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:SingleDetail params:parames success:^(id json) {
        NSLog(@"json---%@",json);
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            SingleListModel *model = [SingleListModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)singleCommentWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg))response
{
    [[GFXNetworkHandle shareHandle]post:SingleComment params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"]);
        }else{
            response(NO,json[@"message"]);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError);
    }];
}

@end
